import { AcupointButtonPanel } from "./AcupointButtonPanel";
import { EventName } from "../../../mvc/EventName";
import { AcupointIntroPanel } from "./AcupointIntroPanel";
import { AcupointRootPanel } from "./AcupointRootPanel";
import { AcupointSavvyPanel } from "./AcupointSavvyPanel";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { LookupPlayerData } from "../LookupPlayerData";
import { AcupointData } from "./AcupointData";
import { DataEvent } from "../../../events/DataEvent";
import { SAcupointInfo } from "../../../../../Message/Game/SAcupointInfo";
type int = number;
//class AcupointPanel
    
    export  class AcupointPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            this._buttonPanel.mode = arg1;
            this._introPanel.mode = arg1;
            this._rootPanel.mode = arg1;
            this._savvyPanel.mode = arg1;
            return;
        }

        /* internal  */init(): void
        {
            this._buttonPanel = new AcupointButtonPanel();
            this._buttonPanel.x = 5;
            this._buttonPanel.y = 3;
            addChild(this._buttonPanel);
            this._buttonPanel.addEventListener(EventName.CurrentAcupointChange, this.onCurrentAcupointChangeHandler);
            this._introPanel = new AcupointIntroPanel();
            this._introPanel.x = 226;
            this._introPanel.y = 3;
            addChild(this._introPanel);
            this._rootPanel = new AcupointRootPanel();
            this._rootPanel.x = 226;
            this._rootPanel.y = 256;
            addChild(this._rootPanel);
            this._savvyPanel = new AcupointSavvyPanel();
            this._savvyPanel.x = 226;
            this._savvyPanel.y = 327;
            addChild(this._savvyPanel);
            return;
        }

        public setAcupointInfo(): void
        {
            var loc1=0;
            var loc2=0;
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    this._acupointInfo = LookupPlayerData.acupointInfo;
                }
            }
            else 
            {
                this._acupointInfo = AcupointData.acupointInfo;
            }
            if (this._acupointInfo) 
            {
                loc1 = this._acupointInfo.acupoint;
                loc2 = this._acupointInfo.step;
                this._buttonPanel.setCurAcupoint(loc2);
                this._buttonPanel.shineButton(loc2);
                this._introPanel.updateIntroInfo(loc1, loc2, true);
                this._rootPanel.updateRootLevel(loc2, this._acupointInfo.roots);
                this._savvyPanel.updateSavvyLevel(loc2, this._acupointInfo.savvys);
                this.updateAcupointAttribute();
                this.updateRootTarget();
            }
            this.guideLevelUp();
            return;
        }

        /* internal  */guideLevelUp(): void
        {
            if (AcupointData.acupointInfo.acupoint == 0 && !AcupointData.isUpgrading && this._mode == GModuleEvent.Mode_Self) 
            {
                this._introPanel.guideLevelUp();
                this._buttonPanel.guideLevelUp();
            }
            return;
        }

        /* internal  */onCurrentAcupointChangeHandler(arg1: DataEvent): void
        {
            if (this._acupointInfo == null) 
            {
                return;
            }
            var loc1=this._acupointInfo.acupoint;
            var loc2=arg1.data as int;
            this._introPanel.updateIntroInfo(loc1, loc2);
            this._rootPanel.updateRootLevel(loc2, this._acupointInfo.roots);
            this._savvyPanel.updateSavvyLevel(loc2, this._acupointInfo.savvys);
            this.updateAcupointAttribute();
            return;
        }

        /* internal  */updateAcupointAttribute(): void
        {
            this._rootPanel.updateRootAttAdd(this._buttonPanel.curStep, this._acupointInfo.rootEffects);
            if (AcupointData.leftTimes > 0 && this._buttonPanel.curStep == this._acupointInfo.step && this._mode == GModuleEvent.Mode_Self) 
            {
                this._introPanel.updateCountdownInfo();
            }
            return;
        }

        public updateCountdown(): void
        {
            this._introPanel.updateCountdownInfo();
            this._buttonPanel.shineButton(AcupointData.acupointInfo.step);
            return;
        }

        public updateNimbus(arg1: int): void
        {
            this._introPanel.updateNimbus(arg1);
            return;
        }

        public updateMoney(): void
        {
            this._introPanel.updateMoney();
            return;
        }

        public updateAcupointInfo(arg1: int): void
        {
            var loc1=0;
            if (arg1 == this._buttonPanel.curStep) 
            {
                loc1 = this._acupointInfo.acupoint;
                this._introPanel.updateIntroInfo(loc1, arg1);
                this._rootPanel.updateRootLevel(arg1, this._acupointInfo.roots);
                this._savvyPanel.updateSavvyLevel(arg1, this._acupointInfo.savvys);
                this.updateAcupointAttribute();
            }
            this._buttonPanel.updateRootTarget();
            return;
        }

        public updateRootTarget(): void
        {
            this._buttonPanel.updateRootTarget();
            return;
        }

        public updateRootBreak(arg1: int): void
        {
            if (this._mode == GModuleEvent.Mode_Self) 
            {
                this._rootPanel.updateRootLevel(arg1, this._acupointInfo.roots);
            }
            return;
        }

        public dispose(): void
        {
            this._buttonPanel.dispose();
            this._introPanel.dispose();
            return;
        }

        /* internal */ /* var */_buttonPanel: AcupointButtonPanel;

        /* internal */ /* var */_introPanel: AcupointIntroPanel;

        /* internal */ /* var */_rootPanel: AcupointRootPanel;

        /* internal */ /* var */_savvyPanel: AcupointSavvyPanel;

        /* internal */ /* var */_acupointInfo: SAcupointInfo;

        /* internal */ /* var */_mode: string="自己";
    }
